/****** ComplexNetwork SQL Setup Script ******/


/****** Object:  Table [dbo].[GraphModels]    Script Date: 03/01/2010 10:33:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GraphModels](
	[GraphModelID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](250) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_GraphModels] PRIMARY KEY CLUSTERED 
(
	[GraphModelID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

/****** Object:  Table [dbo].[GenerationParams]    Script Date: 03/01/2010 10:33:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GenerationParams](
	[GenerationParamID] [int] NOT NULL,
	[Name] [nvarchar](250) NOT NULL,
	[Type] [nvarchar](100) NULL,
 CONSTRAINT [PK_GenerationParams] PRIMARY KEY CLUSTERED 
(
	[GenerationParamID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

/****** Object:  Table [dbo].[AnalyseOptions]    Script Date: 03/01/2010 10:33:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AnalyseOptions](
	[AnalyseOptionID] [int] NOT NULL,
	[Name] [nvarchar](250) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_AnalyseOptions] PRIMARY KEY CLUSTERED 
(
	[AnalyseOptionID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

/****** Object:  Table [dbo].[Assemblies]    Script Date: 06/19/2011 18:33:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Assemblies](
	[AssemblyID] [uniqueidentifier] NOT NULL,
	[ModelID] [int] NOT NULL,
	[Name] [nvarchar](250) COLLATE Cyrillic_General_CI_AS NOT NULL,
	[TimeStamp] [datetime] NULL,
 CONSTRAINT [PK_Assemblies] PRIMARY KEY CLUSTERED 
(
	[AssemblyID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Assemblies]  WITH CHECK ADD  CONSTRAINT [FK_Assemblies_GraphModel] FOREIGN KEY([ModelID])
REFERENCES [dbo].[GraphModels] ([GraphModelID])

/****** Object:  Table [dbo].[GenerationParamValues]    Script Date: 03/01/2010 10:33:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GenerationParamValues](
	[AssemblyID] [uniqueidentifier] NOT NULL,
	[GenerationParamID] [int] NOT NULL,
	[Value] [nvarchar](50) NULL,
 CONSTRAINT [PK_GenerationParamValues] PRIMARY KEY CLUSTERED 
(
	[AssemblyID] ASC,
	[GenerationParamID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[GenerationParamValues]  WITH CHECK ADD  CONSTRAINT [FK_GenerationParamValues_Assemblies] FOREIGN KEY([AssemblyID])
REFERENCES [dbo].[Assemblies] ([AssemblyID])
GO
ALTER TABLE [dbo].[GenerationParamValues] CHECK CONSTRAINT [FK_GenerationParamValues_Assemblies]
GO
ALTER TABLE [dbo].[GenerationParamValues]  WITH CHECK ADD  CONSTRAINT [FK_GenerationParamValues_GenerationParams] FOREIGN KEY([GenerationParamID])
REFERENCES [dbo].[GenerationParams] ([GenerationParamID])
GO
ALTER TABLE [dbo].[GenerationParamValues] CHECK CONSTRAINT [FK_GenerationParamValues_GenerationParams]

/****** Object:  Table [dbo].[AssemblyResults]    Script Date: 03/01/2010 10:33:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AssemblyResults](
	[ResultsID] [int] IDENTITY(1,1) NOT NULL,
	[AssemblyID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_AssemblyResults_1] PRIMARY KEY CLUSTERED 
(
	[ResultsID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[AssemblyResults]  WITH CHECK ADD  CONSTRAINT [FK_AssemblyResults_Assemblies] FOREIGN KEY([AssemblyID])
REFERENCES [dbo].[Assemblies] ([AssemblyID])
GO
ALTER TABLE [dbo].[AssemblyResults] CHECK CONSTRAINT [FK_AssemblyResults_Assemblies]

/****** Object:  Table [dbo].[AnalyzeResults]    Script Date: 03/01/2010 10:33:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AnalyzeResults](
	[ResultsID] [int] NOT NULL,
	[AnalyseOptionID] [int] NOT NULL,
	[Result] [float] NOT NULL,
 CONSTRAINT [PK_AnalyzeResults] PRIMARY KEY CLUSTERED 
(
	[ResultsID] ASC,
	[AnalyseOptionID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[AnalyzeResults]  WITH CHECK ADD  CONSTRAINT [FK_AnalyzeResults_AnalyseOptions] FOREIGN KEY([AnalyseOptionID])
REFERENCES [dbo].[AnalyseOptions] ([AnalyseOptionID])
GO
ALTER TABLE [dbo].[AnalyzeResults] CHECK CONSTRAINT [FK_AnalyzeResults_AnalyseOptions]
GO
ALTER TABLE [dbo].[AnalyzeResults]  WITH CHECK ADD  CONSTRAINT [FK_AnalyzeResults_AssemblyResults] FOREIGN KEY([ResultsID])
REFERENCES [dbo].[AssemblyResults] ([ResultsID])
GO
ALTER TABLE [dbo].[AnalyzeResults] CHECK CONSTRAINT [FK_AnalyzeResults_AssemblyResults]

GO
/****** Object:  Table [dbo].[Coefficients]    Script Date: 05/09/2010 23:01:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Coefficients](
	[ResultsID] [int] NOT NULL,
	[Coefficient] [float] NOT NULL,
	[Count] [int] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Coefficients]  WITH CHECK ADD  CONSTRAINT [FK_Coefficients_AssemblyResults] FOREIGN KEY([ResultsID])
REFERENCES [dbo].[AssemblyResults] ([ResultsID])
GO
ALTER TABLE [dbo].[Coefficients] CHECK CONSTRAINT [FK_Coefficients_AssemblyResults]

GO
/****** Object:  Table [dbo].[Subgraphs]    Script Date: 05/21/2010 11:26:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Subgraphs](
	[ResultsID] [int] NOT NULL,
	[Sub] [int] NOT NULL,
	[Count] [int] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Subgraphs]  WITH CHECK ADD  CONSTRAINT [FK_Subgraphs_AssemblyResults] FOREIGN KEY([ResultsID])
REFERENCES [dbo].[AssemblyResults] ([ResultsID])
GO
ALTER TABLE [dbo].[Subgraphs] CHECK CONSTRAINT [FK_Subgraphs_AssemblyResults]

GO
/****** Object:  Table [dbo].[VertexDegree]    Script Date: 05/09/2010 23:01:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[VertexDegree](
	[ResultsID] [int] NOT NULL,
	[Degree] [int] NOT NULL,
	[Count] [int] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[VertexDegree]  WITH CHECK ADD  CONSTRAINT [FK_VertexDegree_AssemblyResults] FOREIGN KEY([ResultsID])
REFERENCES [dbo].[AssemblyResults] ([ResultsID])
GO
ALTER TABLE [dbo].[VertexDegree] CHECK CONSTRAINT [FK_VertexDegree_AssemblyResults]

GO
/****** Object:  Table [dbo].[ParisiBitArray]    Script Date: 05/23/2010 00:47:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ParisiBitArray](
	[ResultsID] [int] NOT NULL,
	[Bit] [bit] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[ParisiBitArray]  WITH CHECK ADD  CONSTRAINT [FK_ParisiBitArray_AssemblyResults] FOREIGN KEY([ResultsID])
REFERENCES [dbo].[AssemblyResults] ([ResultsID])
GO
ALTER TABLE [dbo].[ParisiBitArray] CHECK CONSTRAINT [FK_ParisiBitArray_AssemblyResults]
GO
/***  Load initial Data ***/

INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (0 ,'None','used for indicating empty selection')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (1 ,'Degree distribution','Degree distribution')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (2 ,'Avarage path','Avarage path length')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (4 ,'Clustering coefficient','Clustering coefficient')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (8 ,'Eigen values','Eigen values')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (16 ,'Cycles with 3 length','Cycles with 3 length')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (32 ,'Diameter','Diameter of graph')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (64 ,'Full subgraph','Propability of k-degree full sub graph existance')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (128 ,'Cycles 3 by eigen values', 'Cycles 3 by eigen values')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (256 ,'Cycles with 4 length', 'Cycles with 4 length')
INSERT INTO AnalyseOptions(AnalyseOptionID,[Name],[Description]) VALUES (512 ,'Cycles 4 by eigen values', 'Cycles 4 by eigen values')

INSERT INTO GraphModels([Name],[Description]) VALUES ('Block-Hierarchic','Block-hierarchic graph model')
INSERT INTO GraphModels([Name],[Description]) VALUES ('Barabasi-Albert','Barabasi-Albert graph model')
INSERT INTO GraphModels([Name],[Description]) VALUES ('Watts-Strogatz','Watts-Strogatz graph model')
INSERT INTO GraphModels([Name],[Description]) VALUES ('Erdos-Renyi','Erdos-Renyi graph model')

INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(1,'Number of verticles','Int32')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(2,'Mean degree','Int32')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(3,'Number of edges','Int32')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(4,'Prime base','Int16')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(5,'Hierarchic levels','Int16')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(6,'Maximum connections','Int16')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(7,'Parisi matrix','bool')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(8,'Lambda value','Int16')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(9,'Motif degree','Int16')
INSERT INTO GenerationParams(GenerationParamID,[Name],[Type]) VALUES(10,'Probability','double')